package ddz;

import java.util.*;

public class lt2 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] b = new int[n];
        int[] e = new int[n];
        int[] beauty = new int[n];
        PriorityQueue<Integer> queue = new PriorityQueue<>(new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                return 0;
            }
        });
        for (int i = 0; i < n; i++) {
            b[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            e[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            beauty[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            int ans = 0;
            int l = b[i], r = e[i], bea = beauty[i];
            for (int j = b[i]; j <= e[i]; j++) {
                if(isBeaty(j, bea)){
                    ans++;
                }
            }
            if(i != n - 1){
                System.out.print(ans + " ");
            }
            else
                System.out.println(ans);
        }
    }
    public static boolean isBeaty(int num, int bea){
        int t = 0;
        while (num != 0){
            t ^= num % 10;
            num = num / 10;
        }
        return t == bea;
    }
}
